package cn.itsource.pet.controller;

import cn.itsource.basic.util.JsonResult;
import cn.itsource.pet.domain.Pet;
import cn.itsource.pet.domain.PetForm;
import cn.itsource.pet.domain.PetTypeForm;
import cn.itsource.pet.domain.SearchMasterMsg;
import cn.itsource.pet.query.PetQuery;
import cn.itsource.pet.service.IOrderPetAcquisitionService;
import cn.itsource.pet.service.IPetService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 宠物订单类
 */
@RestController
@Api(tags = "宠物收购类", description = "宠物收购类")
@RequestMapping("/pet")
public class PetController {
    @Resource
    private IPetService petService;
    @PostMapping("/adopt")
    public JsonResult adopt(@RequestBody Pet pet){
        return null;
    }
    @PostMapping("/pageList")
    public JsonResult pageList(@RequestBody PetQuery petQuery){
        return JsonResult.createSuccess(petService.findPage(petQuery));
    }
    @GetMapping("/shelve/{id}")
    public JsonResult petShelve(@PathVariable Long id){
        petService.petShelve(id);
        return JsonResult.createSuccess();
    }
    @GetMapping("/{id}")
    public JsonResult petDetail(@PathVariable Long id){
        return JsonResult.createSuccess(petService.petDetail(id));
    }
    @GetMapping("/downShelve/{id}")
    public JsonResult downShelve(@PathVariable Long id){
        petService.downShelve(id);
        return JsonResult.createSuccess();
    }
    @PostMapping("/save")
    public JsonResult save(@RequestBody Pet pet){
        petService.save(pet);
        return JsonResult.createSuccess();
    }
    @PostMapping("/queryHomePage")
    public JsonResult queryHomePage(@RequestBody PetQuery petQuery){
        return JsonResult.createSuccess(petService.queryHomePage(petQuery));
    }
    //宠物表
    @GetMapping("/typeNames")
    public JsonResult queryTypeNames(){
        PetForm petForm = petService.queryTypeNames();
        return JsonResult.createSuccess(petForm);
    }
    @GetMapping("/formObject")
    public JsonResult formObject(){
        PetTypeForm petTypeForm = petService.formObject();
        return JsonResult.createSuccess(petTypeForm);
    }
}
